<?php

namespace app\controller;

use app\traits\ControllerTrait;


class ImageAsset extends ControllerTrait
{
    public function Index()
    {
    }

    public function Create($remark = '')
    {
        $param = $this->request->param();
        $rule = [
            "name|资源名称" => "require",
            'owner|归属人' => 'require', // 归属人
            'small|封面图' => 'require',//封面
            'url|原图' => 'require',//原图
        ];
        $this->validate($param, $rule);

        $asset = app('imageAssetModel');
        $uid = create_guid();
        $asset->save([
            'uid' => $uid,
            'name' => $param['name'],
            'owner' => $param['owner'],
            'small' => $param['small'],
            'url' => $param['url'],
            'remark' => $remark ? $remark : ''
        ]);
        $name = $param['name'] .= '上传成功';
        $this->success($asset, $name);
    }

}